package com.xjh.utils.enumutils;

import com.xjh.utils.datautils.StringUtil;
import org.springframework.util.StringUtils;

import java.util.Objects;

/**
 * @author XuJianHua
 * @date 2022-08-30 13:57:03
 * @description 对公付款申请控件枚举
 */
public enum PaymentApplicationColumnEnum {
    ENTRY_DEPARTMENT(1, "entryDepartment", "入账部门"),
    PAYMENT_REASON(2, "paymentReason", "付款事由"),
    PAYMENT_AMOUNT(3, "paymentAmount", "付款金额"),
    PAYMENT_TYPE(4, "paymentType", "付款方式"),
    PAYMENT_DATE(5, "paymentDate", "付款日期"),
    PAYEE(6, "payee", "收款人全称"),
    BANK_NO(7, "bankNo", "银行账号"),
    BANK_NAME(8, "bankName", "开户行"),
    REMARK(9, "remark", "备注说明"),
    ENCLOSURE(10, "enclosure", "附件");


    private Integer type;
    private String controlName;
    private String description;

    PaymentApplicationColumnEnum(Integer type, String controlName, String description) {
        this.type = type;
        this.controlName = controlName;
        this.description = description;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getControlName() {
        return controlName;
    }

    public void setControlName(String controlName) {
        this.controlName = controlName;
    }

    public static PaymentApplicationColumnEnum getEnumByType(Integer type) {
        if (Objects.isNull(type)) return null;
        for (PaymentApplicationColumnEnum e : PaymentApplicationColumnEnum.values()) {
            if (e.getType().equals(type)) return e;
        }
        return null;
    }

    public static PaymentApplicationColumnEnum getEnumByDescription(String description) {
        if (StringUtils.isEmpty(description)) return null;
        for (PaymentApplicationColumnEnum e : PaymentApplicationColumnEnum.values()) {
            if (e.getDescription().equals(description)) return e;
        }
        return null;
    }

}
